package me.znext.learn.android;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;

class DrawView extends View {
  private Paint p = new Paint();
  private float[][] circles;
  public DrawView(Context context) {
    super(context);
    this.setMinimumHeight(500);
    this.setMinimumWidth(300);
  }
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    p.setColor(Color.RED);// 设置红色
    p.setAntiAlias(true);// 设置画笔的锯齿效果。 true是去除，大家一看效果就明白了
    if (circles == null) {
      return;
    }
    for (float[] circle : circles) {
      canvas.drawCircle(circle[0], circle[1], 20, p);// 大圆
    }
  }

  void updateCircles(float[][] circles) {
    this.circles = circles;
    this.invalidate();
  }
}